package com.my.study.manage;

import com.my.study.common.ClientConnectServerThread;
import com.my.study.common.ServerConnectClientThread;

import java.util.HashMap;

/**
 * @author Carlos
 * @version 1.0
 * @Description 管理服务端连接客户端线程
 * @date 2021/7/18 14:29
 * @see ServerConnectClientThread
 **/
public class ManageServerConnectClientThread {

    /**
     * 管理连接线程
     * K -> 用户id
     * V -> 客户端连接服务端线程对象
     */
    private static HashMap<String, ServerConnectClientThread> MANAGE_THREAD = new HashMap<>(16);


    /**
     * 添加线程对象
     *
     * @param userId 用户id
     * @param serverConnectClientThread 线程对象
     */
    public static void addServerConnectClientThread(String userId, ServerConnectClientThread serverConnectClientThread) {
        MANAGE_THREAD.put(userId, serverConnectClientThread);
    }

    /**
     * 获取线程对象
     *
     * @param userId 用户id
     * @return
     */
    public static ServerConnectClientThread getServerConnectClientThread(String userId) {
        return MANAGE_THREAD.get(userId);
    }



}
